# use normal make for this Makefile
#
# Makefile for building user programs to run on top of Nachos
#
# Several things to be aware of:
#
#    Nachos assumes that the location of the program startup routine (the
# 	location the kernel jumps to when the program initially starts up)
#       is at location 0.  This means: start.o must be the first .o passed 
# 	to ld, in order for the routine "Start" to be loaded at location 0
#

# If you are running on SunOS 5.x machines, uncomment the next line
GCCDIR = /auto/home-scf-22/csci402/testgnu/decstation-ultrix/bin/
LDFLAGS = -T newscript -N
ASFLAGS = -mips1
CPPFLAGS = $(INCDIR)

# if you aren't cross-compiling:
# GCCDIR =
# LDFLAGS = -N -T 0
# ASFLAGS =
# CPPFLAGS = -P $(INCDIR)


CC = $(GCCDIR)gcc
AS = $(GCCDIR)as
LD = $(GCCDIR)ld
CPP = $(GCCDIR)cpp

INCDIR =-I../userprog -I../threads
CFLAGS = -G 0 -c $(INCDIR)

all: theaterstaff theatercustomers customer headcustomer movietechnician ticketclerk concessionclerk tickettaker manager lock1 mv wait signal broadcast normalthread notifier start1 negtest

start.o: start.s ../userprog/syscall.h
	$(CPP) $(CPPFLAGS) start.s > strt.s
	$(AS) $(ASFLAGS) -o start.o strt.s
	rm strt.s
	
theaterstaff.o: theaterstaff.c
	$(CC) $(CFLAGS) -c theaterstaff.c -I.
theaterstaff: theaterstaff.o start.o
	$(LD) $(LDFLAGS) start.o theaterstaff.o -o theaterstaff.coff
	../bin/coff2noff theaterstaff.coff theaterstaff
	
theatercustomers.o: theatercustomers.c
	$(CC) $(CFLAGS) -c theatercustomers.c -I.
theatercustomers: theatercustomers.o start.o
	$(LD) $(LDFLAGS) start.o theatercustomers.o -o theatercustomers.coff
	../bin/coff2noff theatercustomers.coff theatercustomers
	
customer.o: customer.c
	$(CC) $(CFLAGS) -c customer.c -I.
customer: customer.o start.o
	$(LD) $(LDFLAGS) start.o customer.o -o customer.coff
	../bin/coff2noff customer.coff customer
			
headcustomer.o: headcustomer.c
	$(CC) $(CFLAGS) -c headcustomer.c
headcustomer: headcustomer.o start.o
	$(LD) $(LDFLAGS) start.o headcustomer.o -o headcustomer.coff
	../bin/coff2noff headcustomer.coff headcustomer
			
movietechnician.o: movietechnician.c
	$(CC) $(CFLAGS) -c movietechnician.c
movietechnician: movietechnician.o start.o
	$(LD) $(LDFLAGS) start.o movietechnician.o -o movietechnician.coff
	../bin/coff2noff movietechnician.coff movietechnician
					
ticketclerk.o: ticketclerk.c
	$(CC) $(CFLAGS) -c ticketclerk.c
ticketclerk: ticketclerk.o start.o
	$(LD) $(LDFLAGS) start.o ticketclerk.o -o ticketclerk.coff
	../bin/coff2noff ticketclerk.coff ticketclerk
			
concessionclerk.o: concessionclerk.c
	$(CC) $(CFLAGS) -c concessionclerk.c
concessionclerk: concessionclerk.o start.o
	$(LD) $(LDFLAGS) start.o concessionclerk.o -o concessionclerk.coff
	../bin/coff2noff concessionclerk.coff concessionclerk
	
tickettaker.o: tickettaker.c
	$(CC) $(CFLAGS) -c tickettaker.c
tickettaker: tickettaker.o start.o
	$(LD) $(LDFLAGS) start.o tickettaker.o -o tickettaker.coff
	../bin/coff2noff tickettaker.coff tickettaker
			
manager.o: manager.c
	$(CC) $(CFLAGS) -c manager.c
manager: manager.o start.o
	$(LD) $(LDFLAGS) start.o manager.o -o manager.coff
	../bin/coff2noff manager.coff manager
			
testread.o: testread.c
	$(CC) $(CFLAGS) -c testread.c
testread: testread.o start.o
	$(LD) $(LDFLAGS) start.o testread.o -o testread.coff
	../bin/coff2noff testread.coff testread
	
lock1.o: lock1.c
	$(CC) $(CFLAGS) -c lock1.c
lock1: lock1.o start.o
	$(LD) $(LDFLAGS) start.o lock1.o -o lock1.coff
	../bin/coff2noff lock1.coff lock1
		
		
mv.o: mv.c
	$(CC) $(CFLAGS) -c mv.c
mv: mv.o start.o
	$(LD) $(LDFLAGS) start.o mv.o -o mv.coff
	../bin/coff2noff mv.coff mv
	
wait.o: wait.c
	$(CC) $(CFLAGS) -c wait.c
wait: wait.o start.o
	$(LD) $(LDFLAGS) start.o wait.o -o wait.coff
	../bin/coff2noff wait.coff wait

signal.o: signal.c
	$(CC) $(CFLAGS) -c signal.c
signal: signal.o start.o
	$(LD) $(LDFLAGS) start.o signal.o -o signal.coff
	../bin/coff2noff signal.coff signal

broadcast.o: broadcast.c
	$(CC) $(CFLAGS) -c broadcast.c
broadcast: broadcast.o start.o
	$(LD) $(LDFLAGS) start.o broadcast.o -o broadcast.coff
	../bin/coff2noff broadcast.coff broadcast
		
normalthread.o: normalthread.c
	$(CC) $(CFLAGS) -c normalthread.c
normalthread: normalthread.o start.o
	$(LD) $(LDFLAGS) start.o normalthread.o -o normalthread.coff
	../bin/coff2noff normalthread.coff normalthread
	
notifier.o: notifier.c
	$(CC) $(CFLAGS) -c notifier.c
notifier: notifier.o start.o
	$(LD) $(LDFLAGS) start.o notifier.o -o notifier.coff
	../bin/coff2noff notifier.coff notifier
	
start1.o: start1.c
	$(CC) $(CFLAGS) -c start1.c
start1: start1.o start.o
	$(LD) $(LDFLAGS) start.o start1.o -o start1.coff
	../bin/coff2noff start1.coff start1

negtest.o: negtest.c
	$(CC) $(CFLAGS) -c negtest.c
negtest: negtest.o start.o
	$(LD) $(LDFLAGS) start.o negtest.o -o negtest.coff
	../bin/coff2noff negtest.coff negtest
	
	
clean:
	rm -f *.o *.coff
	rm customer headcustomer movietechnician ticketclerk concessionclerk tickettaker manager lock1 mv wait signal broadcast normalthread notifier start1 negtest